#pragma once

#include <glm/glm.hpp>
#include "SourceCode/Renderer/Texture.h"

namespace Hazal
{
	class CSubTexture2D
	{
	public:
		CSubTexture2D(const Ref<CTexture2D>& rTexture, float fUnitSize, const glm::vec2& vecMin, const glm::vec2& vecMax);

	public:
		void CalcTexCoord(const glm::vec2& vecCoordsIdx, const glm::vec2& vecSpriteSize = { 1.0f, 1.0f });
		
		inline const Ref<CTexture2D> GetTexture() { return m_pTexture; }
			 
		inline const glm::vec2* GetTexCoord() const { return m_aVecTexCoords; }

	public:
		/// <summary>
		/// Create a SubTexture2D object with a specified texture coordinate
		/// </summary>
		/// <param name="rTexture">The 2D sprite sheet</param>
		/// <param name="fUnitSize">Unite sub texture size</param>
		/// <param name="vecCoordsIdx">The original coord index, based on the same sub texture size</param>
		/// <param name="vecSpriteSize">The size of a texture in the sheet</param>
		/// <returns></returns>
		static Ref<CSubTexture2D> CreateFromCoords(const Ref<CTexture2D>& rTexture, float fUnitSize, const glm::vec2& vecCoordsIdx, const glm::vec2& vecSpriteSize = {1.0f, 1.0f});


	private:
		Ref<CTexture2D> m_pTexture;

		glm::vec2 m_aVecTexCoords[4];
		float m_fUnitSize;
	};
}
